package com.example.rental_system.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.rental_system.mapper.UserMapper;
import com.example.rental_system.pojo.User;
import com.example.rental_system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImp extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean queryByName(String userName) {
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("user_name",userName);
        boolean exists = userMapper.exists(qw);
        return exists;
    }

    @Override
    public IPage<User> queryAllPage(int start, int current) {
        Page<User> userPage=new Page<>(start,current);
        QueryWrapper queryWrapper=new QueryWrapper();
        return userMapper.selectPage(userPage,queryWrapper);
    }

}
